/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sun.scheduler.gui;

import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.io.File;
import java.net.URL;
import java.util.*;
import sun.scheduler.core.resource.*;

import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import sun.scheduler.core.*;
import sun.scheduler.core.job.*;
import sun.scheduler.io.ScheduleReader;
import sun.scheduler.io.ScheduleWriter;

/**
 *
 * @author mfj
 */
public class MainWindow extends javax.swing.JFrame {
    //just for the filechooser

    private ArrayList<Job> jobs = null;
    private ArrayList<Resource> res = null;
    private ArrayList<Job> export = null;
    private Curve c1, c2, c3;
    private ScheduleGraph sG = null;
    private ResourceProfileMap resourceProfileMap;
    private ArrayList<ResourceProfile> resProf;
    private String filenameJob, filenameRes;
    private boolean lvling = false;
    private Date startDate;

    /**
     * Creates new form MainWindow
     */
    public MainWindow() {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        initComponents();

        // Fester Attribute
        this.setLocation((d.width / 2) - (this.getWidth() / 2), (d.height / 2) - (this.getHeight() / 2));
        this.setTitle("Professional Optimizing Software | SUN Enterprises");
        this.setIconImage(new ImageIcon(getClass().getResource("media/favicon.png")).getImage());
        jTextArea1.setText("<html>Click on a node of the TIME/COST<br></br> graph to get further information.</html>");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        jDialog1 = new javax.swing.JDialog();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jButton6 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JSeparator();
        jLabel16 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jDialog3 = new javax.swing.JDialog();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jButton12 = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JSeparator();
        jLabel15 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        plotPanel1 = new sun.scheduler.gui.PlotPanel();
        levelingPanel1 = new sun.scheduler.gui.LevelingPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jProgressBar1 = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel4 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jTextField3 = new javax.swing.JTextField();
        jToggleButton1 = new javax.swing.JToggleButton();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox4 = new javax.swing.JCheckBox();
        jCheckBox5 = new javax.swing.JCheckBox();
        jButton3 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jLabel21 = new javax.swing.JLabel();
        jTextArea1 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        jDialog1.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jDialog1.setTitle("Open");
        jDialog1.setFocusableWindowState(false);
        jDialog1.setIconImage(null);
        jDialog1.setMinimumSize(new java.awt.Dimension(551, 261));
        jDialog1.setResizable(false);
        jDialog1.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                jDialog1WindowClosed(evt);
            }
        });

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/star.png"))); // NOI18N

        jLabel10.setFont(new java.awt.Font("Vrinda", 1, 36)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(102, 102, 102));
        jLabel10.setText("Open...");

        jButton5.setFont(new java.awt.Font("Vrinda", 1, 14)); // NOI18N
        jButton5.setForeground(new java.awt.Color(51, 51, 51));
        jButton5.setText("Open Resource File");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jButton6.setFont(new java.awt.Font("Vrinda", 1, 14)); // NOI18N
        jButton6.setForeground(new java.awt.Color(51, 51, 51));
        jButton6.setText("Open Job File");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jLabel11.setForeground(new java.awt.Color(102, 102, 102));
        jLabel11.setText("Status:");

        jLabel12.setForeground(new java.awt.Color(102, 102, 102));
        jLabel12.setText("Status:");

        jLabel13.setFont(new java.awt.Font("Vrinda", 1, 14)); // NOI18N
        jLabel13.setForeground(new java.awt.Color(102, 102, 102));
        jLabel13.setText("1. Open a JOB file");
        jLabel13.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        jLabel14.setFont(new java.awt.Font("Vrinda", 1, 14)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(102, 102, 102));
        jLabel14.setText("2. Open a RESOURCE file");
        jLabel14.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        jButton4.setFont(new java.awt.Font("Vrinda", 1, 12)); // NOI18N
        jButton4.setForeground(new java.awt.Color(51, 51, 51));
        jButton4.setText("Cancel");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton7.setFont(new java.awt.Font("Vrinda", 1, 12)); // NOI18N
        jButton7.setForeground(new java.awt.Color(51, 51, 51));
        jButton7.setText("Calculate");
        jButton7.setEnabled(false);
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jLabel16.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(102, 102, 102));
        jLabel16.setText("-");

        jLabel19.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        jLabel19.setForeground(new java.awt.Color(102, 102, 102));
        jLabel19.setText("-");

        jLabel5.setForeground(new java.awt.Color(255, 0, 51));
        jLabel5.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLabel5.setVerticalTextPosition(javax.swing.SwingConstants.TOP);

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jDialog1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton7))
                    .addGroup(jDialog1Layout.createSequentialGroup()
                        .addGap(66, 66, 66)
                        .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jDialog1Layout.createSequentialGroup()
                                .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(41, 41, 41)
                                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jDialog1Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel16)))
                        .addGap(18, 18, 18)
                        .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jDialog1Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel19)))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jDialog1Layout.createSequentialGroup()
                        .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jDialog1Layout.createSequentialGroup()
                                .addGap(22, 22, 22)
                                .addComponent(jLabel9)
                                .addGap(11, 11, 11)
                                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jDialog1Layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jDialog1Layout.createSequentialGroup()
                        .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jDialog1Layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(jLabel9))
                            .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(4, 4, 4)
                        .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(4, 4, 4)
                .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jDialog1Layout.createSequentialGroup()
                        .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jDialog1Layout.createSequentialGroup()
                                .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jDialog1Layout.createSequentialGroup()
                                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12)
                            .addComponent(jLabel16)
                            .addComponent(jLabel19))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton4)
                    .addComponent(jButton7))
                .addContainerGap())
        );

        jDialog3.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jDialog3.setTitle("Information");
        jDialog3.setAlwaysOnTop(true);
        jDialog3.setFocusableWindowState(false);
        jDialog3.setIconImage(null);
        jDialog3.setMinimumSize(new java.awt.Dimension(551, 400));
        jDialog3.setResizable(false);

        jLabel17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/star.png"))); // NOI18N

        jLabel18.setFont(new java.awt.Font("Vrinda", 1, 36)); // NOI18N
        jLabel18.setForeground(new java.awt.Color(102, 102, 102));
        jLabel18.setText("About");

        jButton12.setFont(new java.awt.Font("Vrinda", 1, 12)); // NOI18N
        jButton12.setForeground(new java.awt.Color(51, 51, 51));
        jButton12.setText("Close");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jLabel15.setText("jLabel15");
        jLabel15.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/tu.png"))); // NOI18N

        jLabel7.setText("powered by");

        javax.swing.GroupLayout jDialog3Layout = new javax.swing.GroupLayout(jDialog3.getContentPane());
        jDialog3.getContentPane().setLayout(jDialog3Layout);
        jDialog3Layout.setHorizontalGroup(
            jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog3Layout.createSequentialGroup()
                .addGroup(jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jDialog3Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton12))
                    .addGroup(jDialog3Layout.createSequentialGroup()
                        .addGroup(jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jDialog3Layout.createSequentialGroup()
                                .addGap(22, 22, 22)
                                .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 507, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jDialog3Layout.createSequentialGroup()
                                .addGroup(jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jDialog3Layout.createSequentialGroup()
                                        .addGap(22, 22, 22)
                                        .addComponent(jLabel17)
                                        .addGap(11, 11, 11)
                                        .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel7))
                                    .addGroup(jDialog3Layout.createSequentialGroup()
                                        .addGap(12, 12, 12)
                                        .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel20)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jDialog3Layout.setVerticalGroup(
            jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog3Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jDialog3Layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(jLabel17))
                    .addGroup(jDialog3Layout.createSequentialGroup()
                        .addGroup(jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel7)
                            .addGroup(jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel20)
                                .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(4, 4, 4)
                        .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton12)
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(1120, 730));
        setName("Schedule Optimizer");

        jTabbedPane2.setBackground(new java.awt.Color(204, 204, 204));
        jTabbedPane2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Graphs", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Vrinda", 1, 12), new java.awt.Color(102, 102, 102))); // NOI18N
        jTabbedPane2.setTabPlacement(javax.swing.JTabbedPane.LEFT);
        jTabbedPane2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTabbedPane2.setFont(new java.awt.Font("Vrinda", 0, 12)); // NOI18N
        jTabbedPane2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane2MouseClicked(evt);
            }
        });
        jTabbedPane2.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jTabbedPane2MouseMoved(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setMinimumSize(new java.awt.Dimension(707, 445));

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/welcome.png"))); // NOI18N
        jLabel8.setMaximumSize(new java.awt.Dimension(9999, 9999));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 42, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 445, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jTabbedPane2.addTab("", new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/star.png")), jPanel1); // NOI18N

        plotPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                plotPanel1MouseReleased(evt);
            }
        });

        javax.swing.GroupLayout plotPanel1Layout = new javax.swing.GroupLayout(plotPanel1);
        plotPanel1.setLayout(plotPanel1Layout);
        plotPanel1Layout.setHorizontalGroup(
            plotPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 757, Short.MAX_VALUE)
        );
        plotPanel1Layout.setVerticalGroup(
            plotPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 460, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("TIME/COST", plotPanel1);

        javax.swing.GroupLayout levelingPanel1Layout = new javax.swing.GroupLayout(levelingPanel1);
        levelingPanel1.setLayout(levelingPanel1Layout);
        levelingPanel1Layout.setHorizontalGroup(
            levelingPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 757, Short.MAX_VALUE)
        );
        levelingPanel1Layout.setVerticalGroup(
            levelingPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 460, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("Leveling", levelingPanel1);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Open a project and click on a node of the TIME/COST graph to get the schedule shown here!"}
            },
            new String [] {
                ""
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jTable1.setFillsViewportHeight(true);
        jScrollPane2.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setResizable(false);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(700);

        jTabbedPane2.addTab("Schedule", jScrollPane2);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(102, 102, 102));
        jLabel1.setText("Progress ...");

        jButton2.setFont(new java.awt.Font("Vrinda", 1, 12)); // NOI18N
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/export.png"))); // NOI18N
        jButton2.setText("Export");
        jButton2.setEnabled(false);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Vrinda", 2, 10)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(102, 102, 102));
        jLabel2.setText("Copyright© 2012 by SUN Enterprises All Rights Reserved.");
        jLabel2.setOpaque(true);

        jLabel3.setFont(new java.awt.Font("Vrinda", 1, 12)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(102, 102, 102));
        jLabel3.setLabelFor(jTextArea1);
        jLabel3.setText("Summary");
        jLabel3.setToolTipText("Summarizes all the information");

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/logo.png"))); // NOI18N
        jLabel4.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLabel4.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
        jLabel4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabel4MousePressed(evt);
            }
        });

        jButton1.setFont(new java.awt.Font("Vrinda", 1, 12)); // NOI18N
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/open.png"))); // NOI18N
        jButton1.setText("Open");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jTextField3.setForeground(new java.awt.Color(51, 51, 51));
        jTextField3.setText("0");
        jTextField3.setEnabled(false);
        jTextField3.setSelectionColor(new java.awt.Color(255, 255, 153));
        jTextField3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTextField3MouseClicked(evt);
            }
        });
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });
        jTextField3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField3KeyTyped(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField3KeyReleased(evt);
            }
        });

        jToggleButton1.setBackground(new java.awt.Color(255, 255, 255));
        jToggleButton1.setFont(new java.awt.Font("Vrinda", 0, 12)); // NOI18N
        jToggleButton1.setText("Deckungsbetrag");
        jToggleButton1.setEnabled(false);
        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButton1ActionPerformed(evt);
            }
        });

        jCheckBox1.setFont(new java.awt.Font("Vrinda", 0, 11)); // NOI18N
        jCheckBox1.setForeground(new java.awt.Color(0, 204, 204));
        jCheckBox1.setSelected(true);
        jCheckBox1.setText("TIME/COST");
        jCheckBox1.setEnabled(false);
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        jCheckBox4.setFont(new java.awt.Font("Vrinda", 0, 11)); // NOI18N
        jCheckBox4.setForeground(java.awt.Color.green);
        jCheckBox4.setSelected(true);
        jCheckBox4.setText("T/C - ROUNDED");
        jCheckBox4.setEnabled(false);
        jCheckBox4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox4ActionPerformed(evt);
            }
        });

        jCheckBox5.setFont(new java.awt.Font("Vrinda", 0, 11)); // NOI18N
        jCheckBox5.setForeground(java.awt.Color.red);
        jCheckBox5.setSelected(true);
        jCheckBox5.setText("T/C - TRADEOFF");
        jCheckBox5.setEnabled(false);
        jCheckBox5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox5ActionPerformed(evt);
            }
        });

        jButton3.setText("level me!");
        jButton3.setEnabled(false);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sun/scheduler/gui/media/logo_links.png"))); // NOI18N

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Choose a resource to see its leveling", "(after opening and leveling a procect)" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList1.setEnabled(false);
        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jList1MouseReleased(evt);
            }
        });
        jScrollPane3.setViewportView(jList1);

        jLabel21.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        jLabel21.setForeground(new java.awt.Color(102, 102, 102));
        jLabel21.setText("$/MIn.");

        jTextArea1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jTextArea1.setText("Click on a node of the TIME/COST graph to get further information");
        jTextArea1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jTextArea1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel22.setFont(new java.awt.Font("Vrinda", 1, 12)); // NOI18N
        jLabel22.setForeground(new java.awt.Color(102, 102, 102));
        jLabel22.setLabelFor(jTextArea1);
        jLabel22.setText("Curves");
        jLabel22.setToolTipText("Summarizes all the information");

        jLabel23.setBackground(java.awt.Color.red);

        jMenu1.setText("File");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("Open");
        jMenuItem1.setToolTipText("Open Project Files");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setText("Export");
        jMenuItem2.setToolTipText("Export Data");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Info");

        jMenuItem3.setText("About");
        jMenuItem3.setToolTipText("Information about the program");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator1)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jLabel2))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(3, 3, 3)
                                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jTextField3)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel21)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jCheckBox5)
                                                    .addComponent(jCheckBox4)
                                                    .addComponent(jCheckBox1))
                                                .addGap(6, 6, 6)))
                                        .addComponent(jToggleButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(30, 30, 30)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 753, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80, Short.MAX_VALUE)
                .addComponent(jLabel4))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel4)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox5)
                        .addGap(33, 33, 33)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jToggleButton1)
                            .addComponent(jLabel21))
                        .addGap(5, 5, 5)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton2)))
                .addGap(8, 8, 8)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2))
        );

        jTabbedPane2.getAccessibleContext().setAccessibleName("Curve");
        jTabbedPane2.getAccessibleContext().setAccessibleDescription("Curve");
        jTextArea1.getAccessibleContext().setAccessibleName("<html>Click on a node of the TIME/COST<br></br> graph to get further information.</html>");

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /*
     * EXPORT BUTTON (menu)
     */
    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuItem2ActionPerformed
    {//GEN-HEADEREND:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        //TODO THIS IS NOT THE REAL OUTPUT!!!!
        updateExportFile();
        if (export != null) {
            ScheduleWriter.writeToFile(export, startDate, Job.CurveState.Scheduling);
        } else {
            System.out.println("HALT STOP!");
            String warnMessage = "<html>"
                    + "<b><font size=\"6\">Wowowowowoo!</font><br></br> No hurries please... </b></html> "
                    + "\nThere is nothing to export yet! \n Please open a project, optimize and try again!";
            JOptionPane op = new JOptionPane();
            op.showMessageDialog(op, warnMessage, "Chill out bro!", JOptionPane.WARNING_MESSAGE);

        }
    }//GEN-LAST:event_jMenuItem2ActionPerformed
    /*
     * EXPORT BUTTON
     */
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        //TODO THIS IS NOT THE REAL OUTPUT!!!!
        updateExportFile();
        if (export != null) {

            ScheduleWriter.writeToFile(export, startDate, sG.getCurveState());
        } else {
            String warnMessage = "<html>"
                    + "<b><font size=\"6\">Wowowowowoo!</font><br></br> No hurries please... </b></html> "
                    + "\nThere is nothing to export yet! \n Please open a project, optimize and try again!";
            JOptionPane op = new JOptionPane();
            op.showMessageDialog(op, warnMessage, "Chill out bro!", JOptionPane.WARNING_MESSAGE);

        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        _infoMessage();
    }//GEN-LAST:event_jMenuItem3ActionPerformed
    /*
     * OPEN BUTTON (in menu)
     */
    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        jLabel19.setText("-");
        jLabel19.setForeground(Color.GRAY);
        jLabel16.setText("-");
        jLabel16.setForeground(Color.GRAY);
        jButton7.setEnabled(false);
        preProgressBar();
        _openDialog();
        //ScheduleReader.readFile();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed
    /*
     * OPEN "CLOSE"-BUTTON
     */
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        jDialog1.dispose();
        if (export == null) {
            jobs = null;
            res = null;
        }

    }//GEN-LAST:event_jButton4ActionPerformed
    /*
     * OPEN "RESOURCE"-BUTTON
     */
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        try {
            // show wait cursor
            waitCursor();

            JFileChooser fc = new JFileChooser();
            fc.setDialogTitle("Choose a RESOURCE file...");
            fc.setFileFilter(new FileFilter() {

                public String getDescription() {
                    return "resource-File(*.csv)";
                }

                public boolean accept(File f) {
                    return f.getName().toLowerCase().endsWith(".csv")
                            || f.isDirectory();

                }
            });
            int res = fc.showOpenDialog(null);
            if (res == JFileChooser.APPROVE_OPTION) {
                try {
                    filenameRes = (fc.getSelectedFile().getAbsolutePath());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            // SET OK OR ERROR FIELD
            ArrayList<Resource> resTest = new ArrayList<Resource>();
            resTest = ScheduleReader.readResourcesFromFile(filenameRes);
            if (resTest.isEmpty()) {
                jLabel19.setText("Error! Try again!");
                jLabel19.setForeground(Color.RED);
                jDialog1.toFront();
            } else {
                jLabel19.setText("OK!");
                jLabel19.setForeground(Color.GREEN);
                jDialog1.toFront();
                if (jLabel16.getText().equals("OK!")) { // enable "calculate"
                    jButton7.setEnabled(true);
                } else {
                    jButton7.setEnabled(false);
                }
            }

        } catch (Exception e) {
//            jLabel19.setText("Error! Try again!");
//            jLabel19.setForeground(Color.RED);
//            jDialog1.toFront();
            e.printStackTrace();
        } finally {
            // restore default cursor
            defaultCursor();
        }
    }//GEN-LAST:event_jButton5ActionPerformed
    /*
     * INFO "CLOSE"-BUTTON
     */
    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
        jDialog3.dispose();
    }//GEN-LAST:event_jButton12ActionPerformed
    /*
     * OPEN BUTTON (next to EXPORT)
     */
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        jLabel19.setText("-");
        jLabel19.setForeground(Color.GRAY);
        jLabel16.setText("-");
        jLabel16.setForeground(Color.GRAY);
        jButton7.setEnabled(false);
        preProgressBar();
        _openDialog();
    }//GEN-LAST:event_jButton1ActionPerformed
    /*
     * OPEN "JOB"-BUTTON
     */
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        try {
            // show wait cursor
            waitCursor();

            JFileChooser fc = new JFileChooser();
            fc.setDialogTitle("Choose a JOB file...");
            fc.setFileFilter(new FileFilter() {

                public String getDescription() {
                    return "job-File(*.csv)";
                }

                public boolean accept(File f) {
                    return f.getName().toLowerCase().endsWith(".csv")
                            || f.isDirectory();

                }
            });
            int res = fc.showOpenDialog(null);
            if (res == JFileChooser.APPROVE_OPTION) {
                try {
                    filenameJob = (fc.getSelectedFile().getAbsolutePath());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            // SET OK OR ERROR FIELD
            if (!ScheduleReader.isJobFile(filenameJob)) {
                jLabel16.setText("Error! Try again!");
                jLabel16.setForeground(Color.RED);
                jDialog1.toFront();
            } else {
                jLabel16.setText("OK!");
                jLabel16.setForeground(Color.GREEN);
                if (jLabel19.getText().equals("OK!")) { // enable "calculate"
                    jButton7.setEnabled(true);
                } else {
                    jButton7.setEnabled(false);
                }
                jDialog1.toFront();
            }
        } catch (Exception e) {
//            jLabel16.setText("Error! Try again!");
//            jLabel16.setForeground(Color.RED);
//            jDialog1.toFront();
            e.printStackTrace();
        } finally {
            // restore default cursor
            defaultCursor();
        }


    }//GEN-LAST:event_jButton6ActionPerformed
    /*
     * CALCULATE BUTTON
     */
    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        if (jLabel16.getText().equals("Error! Try again!") || jLabel19.getText().equals("Error! Try again!")) {
            jButton7.setEnabled(false);
        } else {
            try {
                // show wait cursor
                waitCursor();
                //close window
                jDialog1.dispose();
                res = ScheduleReader.readResourcesFromFile(filenameRes);
                jobs = ScheduleReader.readJobsFromFile(res, filenameJob);

                startDate = ScheduleReader.getStartDate();
                System.out.println(startDate);

                sG = new ScheduleGraph(jobs);
                Main.computeCostCurve(jobs);

                // TODO richtige ArrayList einlesen
//                sched = new Schedule(null);
//                sched.setJobFile(ScheduleReader.getLastJobFile());
//                sched.setResFile(ScheduleReader.getLastResourceFile());
//                cc = new CostCurve(sched);
                new Thread(new ProgressThread()).start(); // trying to get the proccessbar to work simultaniously
//                cc.run(); // calculate all the stuff

                paintPanel1();
                lvling = false;
                updateExportFile();

                jButton2.setEnabled(true);
                jCheckBox1.setEnabled(true);
                jCheckBox4.setEnabled(true);
                jCheckBox5.setEnabled(true);
                jToggleButton1.setEnabled(true);
                jTextField3.setEnabled(true);
                jButton3.setEnabled(true);
                jTabbedPane2.setSelectedIndex(1);
            } catch (Exception e) {
                e.printStackTrace();
//                jDialog1.setVisible(true);
//                jLabel5.setText("<html><b>There have been serious issues!</b><br></br> Error:" + e.getClass() + "</html>");
            } finally {
                // restore default cursor
                defaultCursor();
            }

        }



    }//GEN-LAST:event_jButton7ActionPerformed
    /*
     * DECKUNGSBETRAG BUTTON
     */
    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
        // TODO add your handling code here:
        try {
            if (jToggleButton1.getModel().isSelected()) {
                jToggleButton1.setBackground(Color.ORANGE);
                plotPanel1.setDeckungsBetrag(Double.parseDouble(jTextField3.getText()));
                if (sG != null) {
                    plotPanel1.getCurves().add(graphPlusBetrag(c3.getCoordinates()));
                }
                plotPanel1.resetSelectedPoint();
                plotPanel1.repaint();
            } else {
                jToggleButton1.setBackground(Color.LIGHT_GRAY);
                plotPanel1.setDeckungsBetrag(0);
                if (sG != null) {
                    checkBoxes();
                }
                plotPanel1.resetSelectedPoint();
            }
        } catch (IllegalArgumentException e) {
            jTextField3.setText("wrong input.");
        }

    }//GEN-LAST:event_jToggleButton1ActionPerformed
    /*
     * DECKUNGSBETRAG INPUT FIELD
     */
    private void jTextField3KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField3KeyTyped
        if (evt.getKeyChar() != '\r' && evt.getKeyChar() != '\n') {

            if (jToggleButton1.getModel().isSelected()) {
                jToggleButton1.setBackground(Color.LIGHT_GRAY);
                jToggleButton1.setSelected(false);
                plotPanel1.setDeckungsBetrag(0);
                checkBoxes();
                plotPanel1.resetSelectedPoint();
            }
        }
    }//GEN-LAST:event_jTextField3KeyTyped

    private void jTextField3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextField3MouseClicked
        // TODO add your handling code here:
        jTextField3.selectAll();
    }//GEN-LAST:event_jTextField3MouseClicked

    private void jDialog1WindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_jDialog1WindowClosed
        // TODO add your handling code here:
        jProgressBar1.setIndeterminate(false);
    }//GEN-LAST:event_jDialog1WindowClosed

    private void jLabel4MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel4MousePressed
        _fart();
    }//GEN-LAST:event_jLabel4MousePressed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        // TODO add your handling code here:
        checkBoxes();
    }//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox4ActionPerformed
        // TODO add your handling code here:
        checkBoxes();
    }//GEN-LAST:event_jCheckBox4ActionPerformed

    private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox5ActionPerformed
        // TODO add your handling code here:
        checkBoxes();
    }//GEN-LAST:event_jCheckBox5ActionPerformed
    /*
     * LEVEL ME BUTTON
     */
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        lvling = true;
        int id = plotPanel1.getSelectedPId();
        //LevelingAlgorithm lvla = new LevelingAlgorithm(schedule);
        /*
         * TODO noes das geht noch nicht resourceProfileMap =
         * lvla.getResourceProfileMap();
         *
         */
        paintLevelPanel();
        System.out.println("JList item: " + jList1.getSelectedIndex() + "\n");
//        if (jList1.getSelectedIndex() == -1) {
//            lvla = new LevelingAlgorithm(schedule, (long) Math.ceil(schedule.getTotalTime()));
//        } else {
//            //TODO RESOURCE PRIORITY??!!
//            ResourceProfile r = resProf.get(jList1.getSelectedIndex());
//            lvla = new LevelingAlgorithm(schedule, (long) Math.ceil(schedule.getTotalTime()));
//            levelingPanel1.setResourceProfiles(r);
//            levelingPanel1.repaint();
//        }
        //lvla.run();

//        System.out.println("Leveling with NodeID:" + id + " done! Endtime: " + endTime + " \njList1 index=" + jList1.getSelectedIndex() + "\nresoourceProfileMap:"+lvla.getResourceProfileMap());
        /*
         * TODO das geht auch noch nicht cc_lvl = new CostCurve(lvla);
         *
         */
        updateExportFile();
        fillTable();
        disableEnableThings();

    }//GEN-LAST:event_jButton3ActionPerformed

    private void jTabbedPane2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane2MouseClicked
        disableEnableThings();
    }//GEN-LAST:event_jTabbedPane2MouseClicked

    private void jTabbedPane2MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane2MouseMoved
        disableEnableThings();
    }//GEN-LAST:event_jTabbedPane2MouseMoved

    private void plotPanel1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_plotPanel1MouseReleased
        lvling = false; // reset lvling!
        updateExportFile();
        writeSummary();
    }//GEN-LAST:event_plotPanel1MouseReleased

    private void jList1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseReleased
        if (resourceProfileMap != null && jList1.isEnabled()) {



            levelingPanel1.setResourceProfiles(resProf.get(jList1.getSelectedIndex()));
            levelingPanel1.repaint();
        }
    }//GEN-LAST:event_jList1MouseReleased

    private void jTextField3KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField3KeyReleased

        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                if (!jToggleButton1.getModel().isSelected()) {
                    jToggleButton1.setSelected(true);
                    jToggleButton1.setBackground(Color.ORANGE);
                    plotPanel1.setDeckungsBetrag(Double.parseDouble(jTextField3.getText()));
                    if (sG != null) {
                    plotPanel1.getCurves().add(graphPlusBetrag(c3.getCoordinates()));
                }
                    plotPanel1.resetSelectedPoint();
                    plotPanel1.repaint();
                } else {
                    jToggleButton1.setSelected(false);
                    jToggleButton1.setBackground(Color.LIGHT_GRAY);
                    plotPanel1.setDeckungsBetrag(0);
                    if (sG != null) {
                        checkBoxes();
                    }
                    plotPanel1.resetSelectedPoint();
                }
            } catch (IllegalArgumentException e) {
                jTextField3.setText("wrong input.");
            }
        }
    }//GEN-LAST:event_jTextField3KeyReleased
    /*
     * method to disable/enable buttons
     */

    private void disableEnableThings() {

        if (this.jobs == null || (jTabbedPane2.getSelectedIndex() != 1 && jTabbedPane2.getSelectedIndex() != 2)) {

            jCheckBox1.setEnabled(false);
            jCheckBox4.setEnabled(false);
            jCheckBox5.setEnabled(false);
            jToggleButton1.setEnabled(false);
            jTextField3.setEnabled(false);
            jButton3.setEnabled(false);
        } else {
            jCheckBox1.setEnabled(true);
            jCheckBox4.setEnabled(true);
            jCheckBox5.setEnabled(true);
            jToggleButton1.setEnabled(true);
            jTextField3.setEnabled(true);
            jButton3.setEnabled(true);

        }
        if (resourceProfileMap == null || jTabbedPane2.getSelectedIndex() != 2) {
            jList1.setEnabled(false);
        } else {
            jList1.setEnabled(true);
            jButton3.setEnabled(false);
            jCheckBox1.setEnabled(false);
            jCheckBox4.setEnabled(false);
            jCheckBox5.setEnabled(false);
            jToggleButton1.setEnabled(false);
            jTextField3.setEnabled(false);
        }
        if (jTabbedPane2.getSelectedIndex() == 1 && resourceProfileMap != null) {
            jList1.setEnabled(true);
        }
    }

    /*
     * method to paint the leveling panel
     */
    private void paintLevelPanel() {
        DefaultListModel model = new DefaultListModel();
        System.out.println("ResourceProvileMap:" + resourceProfileMap);
        if (resourceProfileMap == null) {
            return;
        }
        resProf = new ArrayList<ResourceProfile>();
        Iterator<ResourceProfile> iterator = resourceProfileMap.iterator();
        while (iterator.hasNext()) {
            ResourceProfile r = iterator.next();
            System.out.println("Resourcen Name:" + r.getResource().info.name);
            model.addElement(r.getResource().info.name);
            resProf.add(r);
        }
        jList1.setModel(model);
    }

    /*
     * method to fill the jTable
     */
    private void fillTable() {
        if (!plotPanel1.getSummary().equals("")) {
            int id = plotPanel1.getSelectedPId();
            System.out.println("Filling the Table with the CostCurve-Schedule no." + id + "\nLeveling happened?" + lvling + "\n");
            ScheduleWriter.writeProcessAttributesToJTable(jTable1, Main.getScheduleGraph(id, jobs).getJobs(), startDate, sG.getCurveState());
        }
    }
    /*
     * method to add all 3 curves to a collection and adds it to panel1
     */

    private void paintPanel1() {

        Collection<Curve> curvesp1 = new ArrayList<Curve>();
        try {
            c1 = new Curve(Main.getInitialCurve(), Color.CYAN, Color.LIGHT_GRAY, 1);
            c1.setName("TIME/COST");
            curvesp1.add(c1);
            c2 = new Curve(Main.getRoundetCurve(), Color.GREEN, Color.DARK_GRAY, 1);
            c2.setName("T/C-ROUNDED");
            curvesp1.add(c2);
            c3 = new Curve(Main.getScheduledCurve(), Color.RED, Color.BLACK, 2);
            c3.setName("T/C-TRADEOFF");
            curvesp1.add(c3);

//            if (cc_lvl != null) {
//                Curve c4 = new Curve(c3.getCoordinates(),Color.RED, Color.BLACK, 1);
//                c4.setName("Leveling Curve");
//                curvesp1.add(c4);
//            }
        } catch (Exception e) {
        } finally {

            plotPanel1.setCurves(curvesp1);
            plotPanel1.resetSelectedPoint();
            plotPanel1.repaint();
        }
    }

    private void updateExportFile() {
        if (jobs != null) {
            int id = plotPanel1.getSelectedPId();
            System.out.println("UPDATE EXPORT FILE: Levelin happened? " + lvling);
            if (lvling) {
                System.out.println("export(mit lvling) wird gesetzt!");
                // TODO das geht noch nicht
                //export = cc_lvl.getSchedule(id).getJobs();
                System.out.println("export gesetzt\n");
            } else {
                System.out.println("export(ohne lvling) wird gesetzt!");
                export = Main.getScheduleGraph(id, jobs).getJobs();
                System.out.println("export gesetzt\n");
            }

        }

    }

    /*
     * method to determine which box is checked and print graphs
     */
    private void checkBoxes() {
        Collection<Curve> curvesp1 = new ArrayList<Curve>();
        try {

            if (jCheckBox1.isSelected()) {
                curvesp1.add(c1);
            }
            if (jCheckBox4.isSelected()) {
                curvesp1.add(c2);
            }
            if (jCheckBox5.isSelected()) {
                curvesp1.add(c3);
            }
            if (jToggleButton1.getModel().isSelected()) {
                curvesp1.add(graphPlusBetrag(c3.getCoordinates()));
            }
        } catch (Exception e) {
        } finally {

            plotPanel1.setCurves(curvesp1);
            plotPanel1.resetSelectedPoint();
            plotPanel1.repaint();
        }
    }

    private Curve graphPlusBetrag(ArrayList<Point> aP) {
        try {
            ArrayList<Point> aPNeu = new ArrayList<Point>();
            for (Point p : aP) {
                Point pNeu = new Point();
                pNeu.setLocation(p.getX(), p.getY() + p.getX() * Double.parseDouble(jTextField3.getText()));
                aPNeu.add(pNeu);
            }
            Curve cNeu = new Curve(aPNeu, Color.BLACK, Color.BLACK, 0.5);
            cNeu.setName("T/C + Deckungsbetrag");
            return cNeu;
        } catch (Exception e) {
        }
        return null;
    }

    /*
     * method to play a random fart sound
     */
    private void _fart() {
        try {
            Random r = new Random();
            String str = "media/sound/fart/fart_" + (r.nextInt(8) + 1) + ".WAV";
            Sound s = new Sound(str);
            s.playSoundOnce();
        } catch (Exception e) {
        }
    }

    /*
     * message shown when pressing the "info"-button
     */
    private void _infoMessage() {
        String message = "<html>"
                + "Creator of this cute little applet is SUN Enterprises. All Rights Reserved. </b>"
                + "<br></br><br></br>This is a little application to calculate and optimize a workflow.<br></br>Calculation is based on two <b>CSV</b>-files, one gives information "
                + "about the jobs and one about the resources.<br></br>Feel free to edit your maximum amount of resources, money or work through the interface and press "
                + "\"recalculate\" to refresh the view.<br></br><br></br>"
                + "<br></br><font size=\"3\"> <u><i>Credits:</i></u></font>"
                + "<br></br><i>Coffee and Tea</i> - for keeping Martin alive during his nightlife activities,"
                + "<br></br><i>Alle Farben</i> - music artist, who kept me alive with awesome sound,"
                + "<br></br><i>TU Berlin</i> - for beeing just the greatest uni on earth (not?),"
                + "<br></br><i>Unixpool-Staff</i> - for having and reminding us not to take the jacket downstairs,"
                + "<br></br>and finally the <i>CoMa-Team</i> - we love you guys. We love you and you know it!</html> ";
        jLabel15.setText(message);
        jDialog3.setLocationRelativeTo(this);
        jDialog3.setVisible(true);
    }
    /*
     * dialog shown when pressing the "open"-button
     */

    private void _openDialog() {
        jLabel5.setText("");
        jDialog1.setLocationRelativeTo(this);
        jDialog1.setVisible(true);
    }
    /*
     * method generating a random int
     */

    private int nmbr() {
        Random r = new Random();
        return r.nextInt(250);
    }

    /*
     * method to make wait cursor on all panels
     */
    private void waitCursor() {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        this.plotPanel1.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        this.jPanel1.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        this.levelingPanel1.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        this.jTextField3.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        this.jTextArea1.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        this.jTabbedPane2.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }

    /*
     * method to restore default cursor
     */
    private void defaultCursor() {
        setCursor(Cursor.getDefaultCursor());
        this.plotPanel1.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
        this.levelingPanel1.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
        this.jPanel1.setCursor(Cursor.getDefaultCursor());
        this.jTextField3.setCursor(Cursor.getDefaultCursor());
        this.jTextArea1.setCursor(Cursor.getDefaultCursor());
        this.jTabbedPane2.setCursor(Cursor.getDefaultCursor());
    }

    /*
     * methods to change the progressbar
     */
    private void preProgressBar() {
        // PREPROCESSING

// update progress bar (indeterminate mode)
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                jProgressBar1.setIndeterminate(true);
                jProgressBar1.setString("Preprocessing...");
            }
        });
    }


    /*
     * method to write stuff into the summary box
     */
    private void writeSummary() {
        if (plotPanel1 == jTabbedPane2.getSelectedComponent() && !plotPanel1.getSummary().equals("")) { // first panel selected
            int id = plotPanel1.getSelectedPId();
            String str = "<br></br><i>node id: </i>" + id + "<br></br><i>jobs: </i>"
                    + "<br></br><i>resources: </i>"
                    + "<br></br><br></br>for further details go to the <br></br>\"schedule\"-tab</html>";
            jTextArea1.setText(plotPanel1.getSummary() + str);
            fillTable();
        };
    }

    //TODO delete this method when finished with project
    private void testLeveling() {
        Random r = new Random();
        levelingPanel1.resetaB();
        for (int i = 0; i < 2; i++) {
            levelingPanel1.addaB(r.nextInt(500), r.nextInt(500), r.nextInt(500), r.nextInt(500), "" + i, Color.getHSBColor(r.nextFloat(), r.nextFloat(), r.nextFloat()));
        }
        levelingPanel1.repaint();
    }

    // TODO delete this method when finished with project TEST THINGYS
    private Collection<Curve> plotPanelTestCurves() {

        Collection<Curve> curves = new ArrayList<Curve>();
        for (int j = 0; j < 3; j++) {
            ArrayList<Point> coordinates = new ArrayList<Point>();
            Point p = new Point(0, 0);
            coordinates.add(p);
            for (int i = 0; i < (nmbr()); i++) {
                p = new Point(nmbr(), nmbr());
                coordinates.add(p);
            }
            Random r = new Random();
            Color randomColor = new Color(r.nextFloat(), r.nextFloat(), r.nextFloat());
            Color nodeColor = new Color(r.nextFloat(), r.nextFloat(), r.nextFloat());
            Curve c = new Curve(coordinates, randomColor, nodeColor, r.nextInt(4));
            curves.add(c);
        }
        return curves;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainWindow().setVisible(true);
            }
        });
    }

    private class ProgressThread implements Runnable {

        public void run() {
            proProgressBar();
        }

        private void proProgressBar() {
// perform preprocessing (open input file, determine total number of words, etc)

// PROCESSING 

// update progress bar (switch to determinate mode)
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    jProgressBar1.setIndeterminate(false);
                }
            });

            int count = 0;

            while (count < 200) {
                // read a word from the input file; exit loop if EOF

                // compute soundex representation

                // add entry to map (hash table)

                // compute percentage completed
                count++;
                final int percent = count * 1 / 2;

                // update progress bar on the EDT
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        jProgressBar1.setString("Processing " + percent + "%");
                        jProgressBar1.setValue(percent);
                    }
                });



// POSTPROCESSING 

// update progress bar (switch to indeterminate mode)
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        jProgressBar1.setIndeterminate(true);
                        jProgressBar1.setString("Postprocessing...");
                    }
                });

// perform postprocessing (close input file, etc)

// DONE! 

                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        jProgressBar1.setIndeterminate(false);
                        jProgressBar1.setString("Done!");
                        jProgressBar1.setValue(100);
                    }
                });
            }
        }
    }

    public class Sound // Holds one audio file
    {

        private AudioClip song; // Sound player
        private URL songPath; // Sound path

        Sound(String filename) {
            try {
                songPath = getClass().getResource(filename);
                song = Applet.newAudioClip(songPath); // Load the Sound
            } catch (Exception e) {
            } // Satisfy the catch
        }

        public void playSound() {
            song.loop(); // Play 
        }

        public void stopSound() {
            song.stop(); // Stop
        }

        public void playSoundOnce() {
            song.play(); // Play only once
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JCheckBox jCheckBox5;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JDialog jDialog3;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel jTextArea1;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JToggleButton jToggleButton1;
    private sun.scheduler.gui.LevelingPanel levelingPanel1;
    private sun.scheduler.gui.PlotPanel plotPanel1;
    // End of variables declaration//GEN-END:variables
}
